package com.itheima03.day15Test;

/**
 * @author 刘全
 * @date 2021/8/7
 */
public class Test2 {
    public static void main(String[] args) {
        Object a = new Object();
        Object b = new Object();
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    synchronized (a) {
                        synchronized (b) {
                            System.out.println("第一个线程执行了");
                        }
                    }
                }
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    synchronized (b) {
                        synchronized (a) {
                            System.out.println("第二个线程执行了");
                        }
                    }
                }
            }
        }).start();
    }
}
